/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrmEnter.java
 *
 * Created on 01-dic-2014, 9:03:54
 */
package presentacion;

/**
 *
 * @author jhow
 */
import Negocio.Entero;
import Negocio.Numero_a_Literal;
import javax.swing.JOptionPane;

public class FrmEntero extends javax.swing.JFrame {

    /** Creates new form FrmEnter */
    public FrmEntero() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnPar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        txbNumero = new javax.swing.JTextField();
        btnFactorial = new javax.swing.JButton();
        btnPrimo = new javax.swing.JButton();
        btnInvertir = new javax.swing.JButton();
        btnCapícua = new javax.swing.JButton();
        btnLiteral = new javax.swing.JButton();
        btnFibonaci = new javax.swing.JButton();
        btnSalir = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        btnPar.setText("Par"); // NOI18N
        btnPar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnParActionPerformed(evt);
            }
        });

        jLabel1.setText("Introdusca Numero Entero"); // NOI18N

        btnFactorial.setText("Factorial");
        btnFactorial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFactorialActionPerformed(evt);
            }
        });

        btnPrimo.setText("Primo");
        btnPrimo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPrimoActionPerformed(evt);
            }
        });

        btnInvertir.setText("Invertir");
        btnInvertir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnInvertirActionPerformed(evt);
            }
        });

        btnCapícua.setText("Capicua");
        btnCapícua.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCapícuaActionPerformed(evt);
            }
        });

        btnLiteral.setText("Literal");
        btnLiteral.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLiteralActionPerformed(evt);
            }
        });

        btnFibonaci.setText("Fibonaci");
        btnFibonaci.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFibonaciActionPerformed(evt);
            }
        });

        btnSalir.setText("Salir");
        btnSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(btnPar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnCapícua)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnFactorial)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnPrimo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnSalir))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(btnLiteral)
                                .addGap(2, 2, 2)
                                .addComponent(btnInvertir)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnFibonaci))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(jLabel1)
                                .addGap(18, 18, 18)
                                .addComponent(txbNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(19, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txbNumero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(48, 48, 48)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnPar, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnCapícua, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnFactorial, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnPrimo, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnSalir, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnLiteral, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnInvertir, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnFibonaci, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnParActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnParActionPerformed
    Entero objEntero=new Entero();
objEntero.setNum(Integer.parseInt(this.txbNumero.getText()));

if (objEntero.par() )
{    JOptionPane.showMessageDialog(null, "El Número Es par");
  
}
else {
    JOptionPane.showMessageDialog(null, "El Número NO es par");
    
}
        // TODO add your handling code here:
    }//GEN-LAST:event_btnParActionPerformed

    private void btnCapícuaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCapícuaActionPerformed
       Entero objcap=new Entero();
objcap.setNum(Integer.parseInt(this.txbNumero.getText()));

if ( objcap.Capicua() )
{    JOptionPane.showMessageDialog(null, "El Número Es capicia:  "+this.txbNumero.getText());

}
else {
    JOptionPane.showMessageDialog(null, "El Número NO es capicua:  "+this.txbNumero.getText());
    
}     
          
// TODO add your handling code here:
        
    }//GEN-LAST:event_btnCapícuaActionPerformed

    private void btnPrimoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrimoActionPerformed
Entero objpri=new Entero();
objpri.setNum(Integer.parseInt(this.txbNumero.getText()));

if ( objpri.Primo() )
{    JOptionPane.showMessageDialog(null, "El Número Es Primo");

}
else {
    JOptionPane.showMessageDialog(null, "El Número NO es Primo");
    
}         
// TODO add your handling code here:
    }//GEN-LAST:event_btnPrimoActionPerformed

    private void btnLiteralActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLiteralActionPerformed
Numero_a_Literal NumLetra = new Numero_a_Literal();
String numero ;
numero=NumLetra.Convertir(this.txbNumero.getText(),true);
JOptionPane.showMessageDialog(null,"literal:   "+numero);
// TODO add your handling code here:
    }//GEN-LAST:event_btnLiteralActionPerformed

    private void btnFactorialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFactorialActionPerformed
 Entero objfact=new Entero();
 objfact.setNum(Integer.parseInt(this.txbNumero.getText()));
long cad=objfact.Factorial();
JOptionPane.showMessageDialog(null,cad);

//JOptionPane.showMessageDialog(null, objfact, numero, "");
      
        // TODO add your handling code here:
    }//GEN-LAST:event_btnFactorialActionPerformed

    private void btnFibonaciActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFibonaciActionPerformed
        Entero objfibo=new Entero();
        objfibo.setNum(Integer.parseInt(this.txbNumero.getText()));
        String cad=objfibo.Fibonaci();
        JOptionPane.showMessageDialog(null,cad);        
    }//GEN-LAST:event_btnFibonaciActionPerformed

    private void btnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalirActionPerformed
        frmPrincipal f1=new frmPrincipal();
        f1.setVisible(true);
        this.setVisible(false);
        // TODO add your handling code here:
    }//GEN-LAST:event_btnSalirActionPerformed

    private void btnInvertirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnInvertirActionPerformed
      Entero objinv=new Entero();
        objinv.setNum(Integer.parseInt(this.txbNumero.getText()));
        int cad=objinv.Invertir();
        JOptionPane.showMessageDialog(null,cad);
        // TODO add your handling code here:
    }//GEN-LAST:event_btnInvertirActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FrmEntero().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCapícua;
    private javax.swing.JButton btnFactorial;
    private javax.swing.JButton btnFibonaci;
    private javax.swing.JButton btnInvertir;
    private javax.swing.JButton btnLiteral;
    private javax.swing.JButton btnPar;
    private javax.swing.JButton btnPrimo;
    private javax.swing.JButton btnSalir;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JTextField txbNumero;
    // End of variables declaration//GEN-END:variables

    
}
